<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <title>面向研究团队的参考文献管理与服务分布式系统</title>
    <meta name="keywords" content="面向研究团队的参考文献管理与服务分布式系统" />
    <meta name="description" content="面向研究团队的参考文献管理与服务分布式系统" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link href="../css/bootstrap.min.css" rel="stylesheet" />
    <link href="../css/bootstrap-table.css" rel="stylesheet" />
    <link href="../css/bootstrap-editable.css" rel="stylesheet" />
    <link rel="stylesheet" href="../css/font-awesome.min.css" />
    <link rel="stylesheet" href="../css/ace.min.css" />
    <link rel="stylesheet" href="../css/ace-rtl.min.css" />
    <link rel="stylesheet" href="../css/ace-skins.min.css" />
    <link rel="stylesheet" href="../css/loading/loading.css">
    <script src="../js/ace-extra.min.js"></script>
    <script src="../js/angular.min.js"></script>
    <script src="../js/angular-cookies.min.js"></script>

</head>

<body>

<div class="navbar navbar-default" id="navbar">
    <script type="text/javascript">
        try {
            ace.settings.check('navbar', 'fixed')
        } catch(e) {}
    </script>
    <div class="navbar-container" id="navbar-container">
        <div class="navbar-header pull-left">
            <a href="#" class="navbar-brand">
                <small>
                    <i class="icon-book"></i>

                    面向研究团队的参考文献管理与服务分布式系统
                </small>
            </a>
            <!-- /.brand -->
        </div>
        <!-- /.navbar-header -->

        <div class="navbar-header pull-right" role="navigation">
            <ul class="nav ace-nav">

                <li class="light-blue">
                    <a data-toggle="dropdown" href="#" class="dropdown-toggle">
                        <img class="nav-user-photo" src="../avatars/user.jpg" alt="Jason's Photo" />
                        <span class="user-info">
									<small>欢迎,</small>
									登录
								</span>

                        <i class="icon-caret-down"></i>
                    </a>

                    <ul class="user-menu pull-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close">
                        <li>
                            <a href="#">
                                <i class="icon-cog"></i> 设置
                            </a>
                        </li>

                        <li>
                            <a href="#">
                                <i class="icon-user"></i> 简况
                            </a>
                        </li>

                        <li class="divider"></li>

                        <li>
                            <a href="/ma/user/logout"  class="a_post">
                                <i class="icon-off"></i> 登出
                            </a>
                        </li>
                    </ul>
                </li>
            </ul>
            <!-- /.ace-nav -->
        </div>
        <!-- /.navbar-header -->
    </div>
    <!-- /.container -->

</div>

<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch(e) {}
    </script>

    <div class="main-container-inner">
        <a class="menu-toggler" id="menu-toggler" href="#">
            <span class="menu-text"></span>
        </a>

        <div class="sidebar" id="sidebar">
            <script type="text/javascript">
                try {
                    ace.settings.check('sidebar', 'fixed')
                } catch(e) {}
            </script>

            <!-- #sidebar-shortcuts -->
            <ul class="nav nav-list">
                <li class="active open"><a href="#" class="dropdown-toggle">
                    <i class="icon-book"></i> <span class="menu-text"> 所有参考文献
						</span> <b class="arrow icon-angle-down"></b>
                </a>

                    <ul class="submenu">
                        <li><a href="#" class="dropdown-toggle"> <i
                                class="icon-double-angle-right"></i> 图书 <b
                                class="arrow icon-angle-down"></b>
                        </a>
                            <ul class="submenu">
                                <li><a href="/ma/miuser/Chinesebooks.html"> <i
                                        class="icon-leaf"></i> 中文图书
                                </a></li>
                                <li><a href="/ma/miuser/Chinesebooks1.html"> <i
                                        class="icon-leaf"></i> 西文图书
                                </a></li>

                            </ul></li>

                        <li class="active open"><a href="#" class="dropdown-toggle">
                            <i class="icon-double-angle-right"></i> 同步数据 <b
                                class="arrow icon-angle-down"></b>
                        </a>
                            <ul class="submenu">

                            </ul></li>


                        <li><a href="#" class="dropdown-toggle"> <i
                                class="icon-double-angle-right"></i> 学位论文 <b
                                class="arrow icon-angle-down"></b>
                        </a>

                            <ul class="submenu">
                                <li><a href="#"> <i class="icon-leaf"></i> 中文学位论文
                                </a></li>
                                <li><a href="#"> <i class="icon-leaf"></i> 西文学位论文
                                </a></li>

                            </ul></li>

                        <li><a href="#" class="dropdown-toggle"> <i
                                class="icon-double-angle-right"></i> 技术报告 <b
                                class="arrow icon-angle-down"></b>
                        </a>

                            <ul class="submenu">
                                <li><a href="#"> <i class="icon-leaf"></i> 中文技术报告
                                </a></li>

                                <li><a href="#" class="dropdown-toggle"> <i
                                        class="icon-leaf"></i> 西文技术报告

                                </a></li>
                            </ul></li>

                        <li><a href="#" class="dropdown-toggle"> <i
                                class="icon-double-angle-right"></i> 专利 <b
                                class="arrow icon-angle-down"></b>
                        </a>
                            <ul class="submenu">
                                <li><a href="#"> <i class="icon-leaf"></i> 中文专利
                                </a></li>
                                <li><a href="#"> <i class="icon-leaf"></i> 西文专利
                                </a></li>

                            </ul></li>
                    </ul></li>

                <li><a href="#" class="dropdown-toggle"> <i
                        class="icon-book"></i> <span class="menu-text"> 期刊论文集 </span> <b
                        class="arrow icon-angle-down"></b>
                </a>

                    <ul class="submenu">
                        <li><a href="#" class="dropdown-toggle"> <i
                                class="icon-double-angle-right"></i> 期刊 <b
                                class="arrow icon-angle-down"></b>
                        </a>
                            <ul class="submenu">
                                <li class="active"><a href="/ma/miuser/journalAdd.html"> <i
                                        class="icon-leaf"></i> 中文期刊
                                </a></li>
                                <li><a href="/ma/miuser/journalAdd1.html"> <i class="icon-leaf"></i>
                                    西文期刊
                                </a></li>

                            </ul></li>

                        <li><a href="#" class="dropdown-toggle"> <i
                                class="icon-double-angle-right"></i> 论文集 <b
                                class="arrow icon-angle-down"></b>
                        </a>
                            <ul class="submenu">
                                <li><a href="#"> <i class="icon-leaf"></i> 中文论文集
                                </a></li>
                                <li><a href="#"> <i class="icon-leaf"></i> 西文论文集
                                </a></li>

                            </ul></li>
                    </ul></li>

                <li><a href="/ma/miuser/referenceGroup.html"> <i
                        class="icon-dashboard"></i> <span class="menu-text">
								参考文献分组 </span>
                </a></li>
                <li><a href="/ma/miuser/email2.html"> <i
                        class="glyphicon glyphicon-envelope"></i> <span class="menu-text">
								Email系统 </span>
                </a></li>
                <li><a href="/ma/miuser/message2.html"> <i
                        class="glyphicon glyphicon-comment"></i> <span class="menu-text">
								短信系统 </span>
                </a></li>
                <li><a href="/ma/miuser/indeAdmin.html"> <i
                        class="glyphicon glyphicon-user"></i> <span class="menu-text">
								个人信息 </span>
                </a></li>
                <li><a href="/ma/user/logout" class="a_post"> <i
                        class="glyphicon glyphicon-off"></i> <span class="menu-text">
								退出系统 </span>
                </a></li>


            </ul>
            <!-- /.nav-list -->

            <div class="sidebar-collapse" id="sidebar-collapse">
                <i class="icon-double-angle-left" data-icon1="icon-double-angle-left" data-icon2="icon-double-angle-right"></i>
            </div>

            <script type="text/javascript">
                try {
                    ace.settings.check('sidebar', 'collapsed')
                } catch(e) {}
            </script>
        </div>

        <div class="main-content">
            <div class="breadcrumbs" id="breadcrumbs">
                <script type="text/javascript">
                    try {
                        ace.settings.check('breadcrumbs', 'fixed')
                    } catch(e) {}
                </script>

                <ul class="breadcrumb">
                    <li>
                        <i class="icon-home home-icon"></i>
                        <a href="#">主页</a>
                    </li>

                    <li>
                        <a href="#">同步</a>
                    </li>

                </ul>
                <!-- .breadcrumb -->

                <!-- #nav-search -->
            </div>

            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <div class="row">
                            <div class="col-xs-12">
                                <div class="table-responsive">
                                    <div id="toolbar" class="btn-group row">
                                        <div class="col-md-8" >
                                            <div class="table-header" style="width:60px;background-color:#ffb44b;color:black">
                                                同步
                                            </div>
                                        </div>
                                        <div class="col-md-4">
                                        </div>
                                    </div>
                                    <table style="text-overflow: ellipsis;white-space: nowrap;" id="syn-table">

                                    </table>

                                </div>
                            </div>
                        </div>

                        <!-- PAGE CONTENT ENDS -->
                    </div>
                    <!-- /.col -->
                </div>
                <!-- /.row -->
            </div>
            <!-- /.page-content -->
        </div>
        <!-- /.main-content -->

        <div class="ace-settings-container" id="ace-settings-container">
            <div class="btn btn-app btn-xs btn-warning ace-settings-btn" id="ace-settings-btn">
                <i class="icon-cog bigger-150"></i>
            </div>

            <div class="ace-settings-box" id="ace-settings-box">
                <div>
                    <div class="pull-left">
                        <select id="skin-colorpicker" class="hide">
                            <option data-skin="default" value="#438EB9">#438EB9</option>
                            <option data-skin="skin-1" value="#222A2D">#222A2D</option>
                            <option data-skin="skin-2" value="#C6487E">#C6487E</option>
                            <option data-skin="skin-3" value="#D0D0D0">#D0D0D0</option>
                        </select>
                    </div>
                    <span>&nbsp; 换肤</span>
                </div>

                <div>
                    <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-add-container" />
                    <label class="lbl" for="ace-settings-add-container">
                        居中
                        <b></b>
                    </label>
                </div>
            </div>
        </div>
        <!-- /#ace-settings-container -->
    </div>
    <!-- /.main-container-inner -->

    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="icon-double-angle-up icon-only bigger-110"></i>
    </a>

</div>
<div id="syncModal" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
    <div class="modal-dialog modal-sm" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">提示</h4>
            </div>
            <div class="modal-body">
                <p>确定同步？</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-default confirm">确定</button>
            </div>
        </div>
    </div>
</div>




<div class="modal fade" id="edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">编辑</h4>
            </div>
            <div class="modal-body">

                <form>
                    <div class="row form-inline form-group">
                        <div class="col-md-2"></div>
                        <div class="col-md-6">
                            <label>出版商名称</label>
                            <input type="text" class="form-control" style="width:40%" id="publisher_name_edit">
                        </div>
                    </div>
                    <div class="row form-inline form-group">
                        <div class="col-md-2"></div>
                        <div class="col-md-6">
                            <label>出版商网站</label>
                            <input type="text" class="form-control" style="width:70%" id="publisher_website_edit">
                        </div>
                    </div>
                    <div class="row form-inline form-group">
                        <div class="col-md-2"></div>
                        <div class="col-md-6">
                            <label>出版商缩写</label>
                            <input type="text" class="form-control" style="width:70%" id="abbreviations_edit">
                        </div>
                    </div>
                    <div class="row form-inline form-group">
                        <div class="col-md-2"></div>
                        <div class="col-md-6">
                            <label>出版商所在城市</label>
                            <input type="text" class="form-control" style="width:40%" id="publisher_city_edit">
                        </div>
                    </div>
                    <div class="row form-inline form-group">
                        <div class="col-md-2"></div>
                        <div class="col-md-6">
                            <label>备注</label>
                            <input type="text" class="form-control" style="width:70%" id="note_edit">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span>关闭</button>
                <button type="button" id="btn_submit_edit" class="btn btn-primary" data-dismiss="modal"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>保存</button>
            </div>
        </div>
    </div>
</div>

<script src="../js/jquery-2.0.3.min.js"></script>
<script src="../js/jquery.cookie.js"></script>
<script type="text/javascript">
    if("ontouchend" in document) document.write("<script src='../js/jquery.mobile.custom.min.js'>" + "<" + "/script>");
</script>

<script src="../js/bootstrap.min.js"></script>
<script src="../js/bootstrap-table.js"></script>
<script src="../js/bootstrap-editable.js"></script>
<script src="../js/bootstrap-table-zh-CN.js"></script>
<script src="../js/typeahead-bs2.min.js"></script>
<script src="../js/ace-elements.min.js"></script>
<script src="../js/ace.min.js"></script>
<script src="/ma/mainjs/auth.js"></script>
<script src="../js/loading/loading.js"></script>

<script>
    $("#btn_add").click(function() {
        $('#add').modal();
        $('#btn_submit_add').click(function () {
            $.ajax({
                type: "POST",
                url: "/ma/journal/add-journal",
                contentType: "application/json;charset=utf-8",
                data: JSON.stringify({
                    "name_en": $('#publisher_name_en_add').val(),
                    "name_cn": $('#publisher_name_cn_add').val(),
                    "abbreviation": $('#abbreviation_add').val(),
                    "release_cycles_type": $('#release_cycles_type').val(),
                    "issn": $('#ISSN_pre_add').val()+"-"+$('#ISSN_suffix_add').val(),
                    "publisher_id": $('#publisher_selector').val(),
                    "found_year": $('#found_year_add').val(),
                    "note": $('#note_add').val()
                }),
                dataType: "json",
                success: function (response) {
                    if (response.code == 200) {
                        if (response.data == true) {
                            window.location.reload();
                            alert("成功");
                        }else {
                            alert("失败");
                        }
                    } else {
                        alert(response.message);
                    }
                },
                error: function (message) {
                    alert("添加失败，请稍后添加");
                }
            });
        });
    })
</script>
<script>
    function getlist(request){
        $.ajax({
            type:"POST",
            url:'/ma/sync/list',
            contentType:'application/json;charset=utf-8',
            dataType:'json',
            data:JSON.stringify({
                "pageNo": 1,
                "pageSize": 10
            }),
            success:function (response) {
                request.success({
                    row:response.list,
                });
                $('#syn-table').bootstrapTable('load', response.list);
            },
            error:function(error){
                console.log(error);
            }
        })
    }
    function register(request){
        $.ajax({
            type: "POST",
            url: "/ma/registerEureka",
            contentType: "application/json;charset=utf-8",
            success: function (response) {
                console.log(response)
                if (response == "success") {
                    getlist(request)
                }else{
                    alert("未成功连接服务器，请检查网络后重试！")
                }
            }
        })
    }
    $('#syn-table').bootstrapTable({
        ajax:function(request){
            var load = new Loading();
            load.init();
            load.start();
            $.ajax({
                type: "POST",
                url: "/ma/searchByAppId",
                contentType: "application/json;charset=utf-8",
                success: function (data) {
                    if(data.length!=0){
                        if(data=="failed"){
                            load.stop();
                            alert("未成功连接服务器，请检查网络后重试！")
                        }else{
                            getlist(request)
                            load.stop();
                        }
                    }else {
                        register(request)
                        load.stop();
                    }
                }
            })

        },
        queryParams : function (params) {
            //这里的键的名字和控制器的变量名必须一致，这边改动，控制器也需要改成一样的
            var temp = {
                page_size: params.limit,
                page_no: (params.offset/ params.limit) + 1,
            };
            return JSON.stringify(temp);
        },
        toolbar: '#toolbar', //工具按钮用哪个容器
        striped: true, //是否显示行间隔色
        cache: false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
        pagination: true, //是否显示分页（*）
        sortable: true, //是否启用排序
        sortOrder: "desc", //排序方式
        sidePagination: "client", //分页方式：client客户端分页，server服务端分页（*）
        pageNumber: 1, //初始化加载第一页，默认第一页
        pageSize: 10, //每页的记录行数（*）
        pageList: [10, 25, 50, 100], //可供选择的每页的行数（*）
        search: true, //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
        strictSearch: true,
        /* showColumns: true, */ //是否显示所有的列
        showRefresh: true, //是否显示刷新按钮
        minimumCountColumns: 2, //最少允许的列数
        clickToSelect: true, //是否启用点击选中行
        height: 500, //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
        uniqueId: "indexNo", //每一行的唯一标识，一般为主键列
        showToggle: true, //是否显示详细视图和列表视图的切换按钮
        cardView: false, //是否显示详细视图
        detailView: false,
        editable: true,
        toolbarAlign: "left",
        columns: [
            {
                formatter: function (value, row, index) {
                    return index+1;
                },
                width:30,
                align: 'center',
                title: '序号'
            },
            {
                field: 'indexNo',
                title: '索引号',
                align: 'center',
                sortable: true
            },
            {
                field: 'item',
                title: '操作内容',
                align: 'center',
                sortable: true

            },
            {
                field: 'indexCodeValue',
                title: '操作文献的类型',
                align: 'center',
                sortable: true
            },
            {
                field: 'statusValue',
                title: '操作类型',
                align: 'center',
                sortable: true
            },
            {
                field: 'stamp',
                title: '操作时间',
                align: 'center',
                sortable: true

            },
            {
                title: '操作',
                field: 'check',
                align: 'center',
                formatter: function(value, row, index) {
                    var d = '<a class = "sync" href="#" mce_href="#" ><i class="icon-upload bigger-180"></i></a> ';
                    return  d;
                },
                events: 'operateEvents'
            }]

    });


    window.operateEvents = {
        'click .sync': function (e, value, row, index) {
            $('#syncModal').modal();
            $("#syncModal .confirm").click(function (e) {
                $.ajax({
                    type: "POST",
                    contentType: "application/json;charset=utf-8",
                    dataType: 'json',
                    url: '/ma/sync/entity',
                    async : false,
                    data: JSON.stringify({
                        "indexNo": row.indexNo,
                        "indexCode": row.indexCode,
                        "status": row.status,
                        "item": row.item,
                        "stamp": row.stampTime
                    }),
                    success: function (response) {
                        if (response.code == 0) {
                            alert(response.message)
                            $('#syncModal').modal('hide');
                        } else {
                            alert(response.message);
                        }
                    }
                });
            })
        }
    };
</script>
</body>
</html>